import java.util.Scanner;


public class FiboAss 
{
	static int array[];
	public static void main(String[] args) 
	{
		Scanner s = new Scanner(System.in);
		System.out.println("Enter the size of the list to be sorted:Default is 5");
		
		int size =5;
		
		try
		{
			size = s.nextInt();
		}
		catch(Exception e)
		{
			size =5;
			s= new Scanner(System.in);
			System.out.println("Default size is set as 5:"+e+"\n");
		}
		
		System.out.println("Enter the number to be sorted:");
					
		int i=0,temp;
		array = new int[size];
		
		while(i<size)
		{
			try
			{
				array[i] = s.nextInt();
				i++;					
			}
			catch(Exception e)
			{
				System.out.println("Invalid value entered:"+e);
				s = new Scanner(System.in);
			}
		}
		
//checking for fibo series starts here
		FiboAss obj = new FiboAss();
		boolean Fiboseries = true;
		for (i=0;i<size;i++)
		{
			if (Fiboseries == true)
			{
				temp = obj.fiboMethod(i);
				if (temp != array[i])
					Fiboseries = false;
			}
		}
		
		if (Fiboseries)
			System.out.println("\nThe Given series is a Fibo Series");
		else
			System.out.println("\nThe given series is not a Fibo Series");
}
	public int fiboMethod(int n)
	{
		if (n ==0 || n ==1)
			return array[n];
		else
			return (fiboMethod(n-1)+fiboMethod(n-2));
	}

}
